module: improve error message for invalid data URL#37701
module: improve error message for invalid data URL#37701aduh95 merged 1 commit intonodejs:masterfrom
Conversation
114e4c8 to
68fcf83
Compare
|
@nodejs/modules |
DerekNonGeneric
left a comment
There was a problem hiding this comment.
Just my 2¢. Not sure that error code has been used for this purpose historically.
|
CC: @ljharb since this mentions MIME to user |
|
to clarify a bit, these should have been picked up and could have been generated in the past |
|
Seems fine to me, since anyone using a data URL is already familiar with MIMEs (this is ofc not true for almost every other specifier category). |
|
Ping @nodejs/modules for reviews. |
DerekNonGeneric
left a comment
There was a problem hiding this comment.
Aside from my outstanding comments (non-blocking), everything else looks pretty good to me.
I will be digging around this part of codebase in a few days, so I will report back if I find issues.
guybedford
left a comment
There was a problem hiding this comment.
Perhaps Unsupported MIME "text/plain" loading "data:text/plain,export default 0".
Also it could be nice if we could support the parent context for tracing where it comes from eg if it were import('data:...') in a module, it helps to know where the import expression is.
|
@guybedford Agreed, although I think this would deserve its own PR to align with other |
|
@aduh95 I do think it's important to move the "unsupported MIME" part to the beginning of the message though. This is because the data URL could be of any length, so that when scanning the error the user should be able to easily see the "unsupported MIME" part first. It also fixes that the current error isn't quite gramatically complete without a comma or colon or something type of break otherwise. Alternatively to make it gramatically correct:
|
|
I went to the last suggestion as it was the easiest to implement. I think you have a point regarding very long specifiers occulting the reason, maybe we can fix that in a similar way as proposed in #37852 (comment)? |
I believe the feature request outlined in #37581 is precisely the error property we need. |
Fixes: nodejs#37647 PR-URL: nodejs#37701 Reviewed-By: Derek Lewis <DerekNonGeneric@inf.is> Reviewed-By: Guy Bedford <guybedford@gmail.com>
f5ed39f to
46062a0
Compare
|
Landed in 46062a0 |
Fixes: #37647
Changes the error message when importing module with an unknown/unsupported MIME type from:
to